import {request,brandId,ajaxRequest} from './request'

import qs from 'qs'
const get="GET";
const post ="POST";
const size=20;




//参数
export function addH5Params(){
    let phone=localStorage.getItem("phone")
    let token=localStorage.getItem("token")
    let brandId=localStorage.getItem("brandId")
    let userId=localStorage.getItem("userId")
    let ip=ip
    return params={
        "phone":phone,
        "token":token,
        "brandId":brandId,
        "user_id":userId,
        "ip":ip,
        "type":"app"
    }
}
//新请求支付接口
export function queryExecuteNewPayApi(brandId,userId,phone,amount,channeTag,channelInfoName,channelParams,bankCard,creditBankName){
    return request({
        url:"facade/app/topup/new",
        method:post,
        data:qs.stringify({
            "brandId":brandId,
            "userId":userId,
            "phone":phone,
            "amount":amount,
            "channeTag":channeTag,
            "orderDesc":"在线收款【"+channelInfoName+" ("+ channelParams+ ") 】",
            "bankCard":bankCard,
            "creditBankName":creditBankName
        })
    })
}
//新根据银行卡和金额获取支持的快捷通道接口
export function queryNewSupportChannelApi(userId,brandId,bankCard,amount,recommend){
    return request({
        url:"user/app/channel/getchannel/bybankcard/andamount",
        method:post,
        data:qs.stringify({
            "userId":userId,
            "brandId":brandId,
            "bankCard":bankCard,
            "amount":amount,
            "recommend":recommend
        })
    })
}
//新设置默认银行卡的接口
export function executeNewSetDefaultBankCardApi(userId,bankCard,type){
    return request({
        url:"user/app/bankcard/create/isdefault",
        method:post,
        data:qs.stringify({
            "userId":userId,
            "bankCard":bankCard,
            "type":type
        })

    })
}

//校验支付密码接口
export function queryPayPasswordInfoApi(toekn,paypass){
    return request({
        url:"user/app/paypass/auth/"+toekn,
        method:post,
        data:qs.stringify({
            "paypass":paypass
        })
    })
}

//易联购买产品接口
export function queryBuyProductionUrlByYiLianApi(brandId,phone,amount,orderDesc,
    channeTag,productId,bankCard,difference){
    return request({
        url :"facade/app/purchase/",
        method:post,
        data:qs.stringify({
            "brandId":brandId,
            "phone":phone,
            "amount":amount,
            "order_desc": "购买产品【"+orderDesc+"】",
            "channe_tag":channeTag,
            "product_id":productId,
            "bank_card":bankCard,
            "difference": difference==""?"":1
        })
    })
}

//查询充值方式接口 
export function queryRechargeWayApi(userId){
    return request({
        url:"/user/app/channel/query/all/brandid",
        method:post,
        data:qs.stringify({
            "user_id":userId,
            "isPurchaseUpgrade":1
        })
    })
}
//查询产品通道信息接口 等级
export function queryChannelInfoByProductionIdApi(thirdLevelId){
    return request({
        url:"user/app/thirdlevel/rate/query/thirdlevelid/",
        method:post,
        data:qs.stringify({
            "thirdLevelId":thirdLevelId
        })
    })
}

//查询贴牌所有产品接口 
export function queryAllProductsApi(brandId){
    return request({
        url:"user/app/thirdlevel/prod/brand/"+brandId,
        method:get,
    })
}

//查询交易明细接口
export function queryTransactionOrderInfoApi(token,userId,page,status,type,channelType){
    return request({
        url:"transactionclear/app/payment/query/"+token,
        method:post,
        data:qs.stringify({
            "userid":userId,
            "page":page,
            "size":size,
            "status":status,
            "type":type,
            'channelType':channelType
        })
    })
}
//查询返佣明细接口
export function queryRebateDetailsInfoApi(phone,strTime,endTime,page){
    return request({
        url:"transactionclear/app/query/all/profit/",
        method:post,
        data:qs.stringify({
            "getphone":phone,
            "strTime":strTime,
            "endTime":endTime,
            "size":size,
            "page":page

        })
    })
}
//查询手机归属地接口
export function queryMobileAreaInfoApi(phone){
    return ajaxRequest({
        
        url:"cc/json/mobile_tel_segment.htm",
        method:post,
        // headers:{
        //     "Content-Type": "Access-Control-Allow-Origin: *"
        //  },
        data:qs.stringify({
            "tel":phone
        })
    })

}


//查询分润明细接口
export function queryProfitDetailsInfoApi(userId,start_time,end_time,page){
    return request({
        url:"transactionclear/app/profit/query/all/",
        method:post,
        data:qs.stringify({
            "userid":userId,
            "start_time":start_time,
            "end_time":end_time,
            "size":size,
            "page":page
        })
    })
}
//分润转至余额接口
export function executeTransferToBalanceApi(phone,order_desc,amount,brandId){
    return request({
        url:"facade/app/withdraw/rebate/",
        method:post,
        data:qs.stringify({
            "phone":phone,
            "order_desc":order_desc,
            "amount":amount,
            "brandId":brandId


        })
    })
}
//修改默认提现卡接口 
export function queryModifyDefaultWithdrawalsCardInfoApi(token,cardno){
    return request({
        url :"user/app/bank/default/"+token,
        method:post,
        data:qs.stringify({
            "cardno":cardno
        })

    })
}
//删除银行卡接口
export function queryDelBankCrad(token,cardno,type){
    return request({
        url:"user/app/bank/del/"+token,
        method:post,
        data:qs.stringify({
            "cardno":cardno,
            "type":type
        })
    })
}
//完善储蓄卡开户省市信息
export function queryModificationOfSavingsCardApi(userId,bankCardNumber,province,city){
    return request({
        url :"user/app/bank/set/bankinfo/province/city",
        method:post,
        data:qs.stringify({
            "userId":userId,
            "bankCardNumber":bankCardNumber,
            "province":province,
            "city":city
        })
    })
}
//完善信用卡账单日还款日信息
export function queryCreditCardModificationApi(userId,bankCardNumber,securityCode,expiredTime,billDay,repaymentDay,creditBlance){
     return request({
        url:"/user/app/bank/set/bankinfo",
        method:post,
        data:qs.stringify({
            "userId":userId,
            "bankCardNumber":bankCardNumber,
            "securityCode":securityCode,
            "expiredTime":expiredTime,
            "billDay":billDay,
            "repaymentDay":repaymentDay,
            "creditBlance":creditBlance
        })
     });
    }

//添加银行卡接口
export function queryExecuteAddBankCardApi(token,realname,bankcard,idcard,mobile,type,
    securitycode,expiretime,billDay,repaymentDay,creditBlance,province,city){
    return request({
        url:"user/app/bank/add/"+token,
        method:post,
        data:qs.stringify({
            "realname":realname,
            "bankcard":bankcard,
            "idcard":idcard,
            "mobile":mobile,
            "type":type,
            "securitycode":securitycode,
            "expiretime":expiretime,
            "billDay":billDay,
            "repaymentDay":repaymentDay,
            "creditBlance":creditBlance,
            "province":province,
            "city":city
        })

    })
}

//查询身份证信息接口
export function queryCertificationInfoApi(token){
    return request({
        url:"paymentchannel/app/realname/"+token,
        method:get
    })
}

// 查询银行卡图标和背景色
export function queryCardPicApi(){
    return request({
        url: '/user/app/bank/get/bankpicture',
        method: 'get',
    })
}
//获取用户所有银行卡接口
export function queryAllBankCardInfoApi(token){
    return request({
        url:"user/app/bank/query/userid/"+token,
        method:get
    })
}

//查询团队收益金额
export function querySelectTeamRevenueListApi(preUserId,startDay,endDay){
    return request({
        url:"statistics/app/query/team/amount/new",
        method:post,
        data:qs.stringify({
            "preUserId":preUserId,
            "startDay":startDay,
            "endDay":endDay,
        })
    })
}
//查询团队收益
export function querySelectTeamRevenueApi(preUserId,startDay,endDay){
    return request({
        url:"user/app/sum/team/rebate",
        method:post,
        data:qs.stringify({
            "preUserId":preUserId,
            "startDay":startDay,
            "endDay":endDay,
        })
    })
}

//  获取指定等级下级会员接口
export function queryMemberDetailInfoApi(token,grade,pages,lower_level){
   return request({
    url:"user/app/info/"+token,
    method:post,
    data:qs.stringify({
        "grade":grade,
        "size":size,
        "page":pages,
        "lower_level":lower_level
    })
   })
}

//查询推广信息
export function querySubMemberStatus(userId){
    return request({
        url:"user/app/query/userteam",
        method:post,
        data:qs.stringify({
            "userId":userId
        })
    })
}
//查询我的推广信息接口
export function queryMySpreadInfoApi(token){
    return request({
        url:"user/app/usersys/query/"+token,
        method:post
    })
}

//查询用户通道费率信息接口
export function queryChannelInfoByUserIdApi(userId){
    return request({
        url:"user/app/channel/query/all/brandid/",
        method:post,
        data:qs.stringify({
            "user_id":userId
        })
    })
}
//查询收益排行榜接口
export function queryIncomeRankingInfoApi(userId,brandId){
    return request({
            url:"user/app/rebate/query/ranking/list/",
            method:post,
            data:qs.stringify({
                "userId":userId,
                "brandId":brandId
            })
    })
}
// 登录
export function getApiLogin(phone,password){
    return request({
        url:"user/app/login/",
        method:post,
        headers:{
            "Content-Type": "application/x-www-form-urlencoded"
         },
        data:qs.stringify({
            'phone':phone,
            'password':password,
            'brand_id':brandId,
        })
    })
}

// 发短信
export function getApiSms(phone){
    return request({
        url:'notice/app/sms/send?phone='+phone+'&brand_id='+brandId,
        method:get
    })
}

//注册接口

export function getApiRegister(phone,vericode,password,invitees){
    return request({
        url: 'user/app/register/',
        method:post,
        data:qs.stringify({
            "brand_id":brandId,
            "phone":phone,
            "vericode":vericode,
            "password":password,
            "invitecode":invitees
            
        })
      })
}

//修改密码接口
export function getApiForgetPassword(phone,password,vericode){
    return request({
        url:"user/app/password/update",
        method:post,
        data:qs.stringify({
            "brandId":brandId,
            "phone":phone,
            "password":password,
            "vericode":vericode
        })
    })
}



//查询用户个人信息接口
export function queryUserInfoApi(token) {
    return request({
        url:"user/app/info/query/"+token,
        method:get,
        
    })
}


//查询总收益接口
export function queryIncomeInfoApi(userId) {
    return request({
        url:"user/app/rebate/query/sumrebate",
        method:post,
        data:qs.stringify({
            "user_id":userId
        })
    })
}

//获取头像接口
export function queryHeaderImageInfoApi(phone,brandId) {
    return request({
        url:"user/app/headportrait/getby/phone/",
        method:post,
        data:qs.stringify({
            "phone":phone,
            "brandId":brandId
        })
    })
    
}
//平台消息接口
export function querySystemHistoryMessageInfoApi(token,page) {
    return request({
        url:"user/app/jpush/history/brand/"+token,
        method:get,
        params:qs.stringify({
            "page":page,
            "size":size
        })
        

    })
}
// 查询轮播图信息接口
export function queryCarouselInfoApi(brandId) {
    return request({
        url:"user/app/slideshow/query/brandid/",
        method:post,
        data:qs.stringify({
            "brand_id":brandId,
            "type":0 // 0 :默认 ,1:额外 
        })
    })   
}



//新查询用户的银行卡信息接口
export function queryNewUserBankCardsApi(userId,type,nature,isDefault){
    return request({
        url:"user/app/bank/query/byuseridandtype/andnature",
        method:post,
        data:qs.stringify({
            "userId":userId,
            "type":type,
            "nature":nature,
            "isDefault":isDefault
        })
    })
}

// 添加银行卡接口 绑定支付宝

export function executeAddZFB(realname,bankcard,idcard,mobile){
    return request({
        url:"user/app/bank/add/",
        method:post,
        data:qs.stringify({
            "realname":realname,
            "bankcard":bankcard,
            "idcard":idcard,
            "mobile":mobile,
            "type":3
        })
    })
}
//查询新闻分类接口
export function queryNewsCategoryApi(){
    return request({
        url:"user/app/newsclassification/getclassification/bybrandid/",
        method:post,
        data:qs.stringify({
            "brandId":brandId
        })
    })
}
// 查询新闻信息接口
export function queryNewsInfoTitleApi(brandId,classifiCation,title,page){
    return request({
        url:"user/app/news/getnewsby/brandidandclassification/andpage/",
        method:post,
        data:qs.stringify({
            "brandId":brandId,
            "classifiCation":classifiCation,
            "title":title,
            "size":size,
            "page":page
        })
    })
}
export function queryNewsInfoApi(brandId,classifiCation,page){
    return request({
        url:"user/app/news/getnewsby/brandidandclassification/andpage/",
        method:post,
        data:qs.stringify({
            "brandId":brandId,
            "classifiCation":classifiCation,
            "size":size,
            "page":page
        })
    })
}

//查询贴牌信息接口
export function queryOemInfoApi(brandId){
    return request({
        url:"user/app/brand/query/id",
        method:get,
        params:{
            'brand_id':brandId 
        }
    })
}

//查询文案信息接口
export function queryCopyWritingInfoApi(brandId){
    return request({
        url:"user/app/imagetext/query/brandid/",
        method:post,
        data:qs.stringify({
            "brand_id":brandId
        })
    })
}

//前端查询配置 brandId
export function querySelectToConfigure(brandId){
    return request({
        url:"user/app/get/brand/config",
        method:post,
        data:qs.stringify({
            "brandId":brandId
        })
    })
}
//上传实名认证图片接口

export function uploadRealNameCertificationImage(data){
    return request({
        url:"user/app/upload/realname/",
        method:post,
        data:data

    })
}
//校验实名信息接口
export function executeVerifyRealNameInfoApi(token,realname,idcard){
    return  request({
        url:"paymentchannel/app/realname/auth/"+token,
        method:post,
        data:qs.stringify({
            "realname":realname,
            "idcard":idcard
        })
    })
}

// 查询账户信息接口
export function queryAccountInfoApi(token){
    return request({
        url:"user/app/account/query/"+token,
        method:get
    })
}


